<?php require_once("admin-header.php");?>
<?php if (!(isset($_SESSION['administrator']))){
	echo "<a href='../loginpage.php'>Please Login First!</a>";
	exit(1);
}
if(isset($_POST['do'])){
	require_once("../include/check_post_key.php");
	$user_id=mysql_real_escape_string($_POST['user_id']);
	$rightstr =$_POST['rightstr'];
	$sql="insert into `privilege` values('$user_id','$rightstr','N')";
	mysql_query($sql);
	if (mysql_affected_rows()==1) echo "<div class='alert alert-success'>$user_id $rightstr 权限已添加!</div>";
	else echo "<div class='alert alert-danger'>木有此用户啊</div>";
}
?>

<center><h2>添加用户权限</h2></center>

<form class="form-horizontal col-sm-6 col-sm-offset-2" action="privilege_add.php" method="post">
    <?php require("../include/set_post_key.php");?>
    <div class="form-group">
        <label class="col-sm-5 control-label">用户</label>
        <div class="col-sm-7">
        <input class="form-control" name="user_id" type="text"/></div>
    </div>
	<div class="form-group">
	<label class="col-sm-5 control-label">权限</label>
	<div class="col-sm-7">
	<select class="form-control" name="rightstr">
       <option value="administrator">系统管理员</option>
       <option value="problem_editor">题目管理员</option>
       <option value="source_browser">查看代码</option>
       <option value="contest_creator">比赛管理员</option>
       <option value="password_setter">密码管理员</option>
	   <option value="http_judge">评测机用户</option>
	   
    </select>
	</div>
	</div>
	<input type='hidden' name='do' value='do'>
	<div class="form-group">
        <div class="col-sm-offset-5 col-sm-7">
            <input type="submit" class="btn btn-primary col-sm-8" value="添加"/>
        </div>
    </div>
</form>



